﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class HistoryItem : MonoBehaviour
{
    public Text m_Price;
    public Text m_Scale;
    Stock m_Stock;
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void Init(Stock stock, int pastDayNumber)
    {
        Debug.Log("Stock Seed:" + (int)stock.m_ID);
        int daySeed = UtilsGame.GetSeedToday() - pastDayNumber;
        float price = stock.CalcPriceAtOneday(daySeed);
        m_Price.text = "$"+price.ToString("F2");
        float rate = stock.GetRateAtOneday(daySeed);
        m_Scale.text = rate.ToString("F2")+"%";
        if (rate > 0)
            m_Scale.color = new Vector4(0, 1, 0, 1);
        else
            m_Scale.color = new Vector4(1, 0, 0, 1);

    }
}
